/*
 * @Author: your name
 * @Date: 2021-05-28 10:06:51
 * @LastEditTime: 2021-05-28 10:13:46
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \bazai_music_api\utils\callCloudDB.js
 */
const { getAccessToken } = require('../utils/getAccessToken.js')
const { default: axios } = require('axios')

const callCloudDB = async (ctx, fnName, query = {}) => {
    const access_token = await getAccessToken()
    const url = `https://api.weixin.qq.com/tcb/${fnName}?access_token=${access_token}`
    try {
        const result = await axios.post(url, {
            query,
            env: ctx.state.env
        })
        return result
	} catch (err) {
		console.log('ACCESS_TOKEN,err', err)
	}
}

module.exports = callCloudDB
